<template>
  <div class="situational-awareness">
    <div class="situational-awareness-content">
      <transition name="fade-transform" mode="out-in">
        <component :is="currentTabCom"></component>
      </transition>
    </div>
    <div class="bottom-tab-list">
      <div :class="['tab-item', item.value === currentTab ? 'active' : '']" v-for="(item, index) in bottomTabList" :key="index" @click="changeTab(item.value)">
        <div class="icon-container">
          <img :src="item.value === currentTab ? item.activeIcon : item.defaultIcon" alt="图标" />
        </div>
        <div class="bottom-sword">
          <img :src="item.value === currentTab ? activeBottomSword : defaultBottomSword" alt="下提示箭头" />
        </div>
        <div class="tip">{{ item.label }}</div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import getBottomMenu, { IMenuItem } from './bottomTabData'
import all from './all/index.vue'
import securityPeople from './securityPeople/index.vue'
import warningDetail from './warningDetail/index.vue'
import caseEvent from './caseEvent/index.vue'
import faceEarlyWarning from './faceEarlyWarning/index.vue'
import prohibitedProduct from './prohibitedProduct/index.vue'
import actualTimeCar from './actualTimeCar/index.vue'
import coachBusWay from './coachBusWay/index.vue'
import busWay from './busWay/index.vue'
import busStation from './busStation/index.vue'
import passengerStation from './passengerStation/index.vue'
import serviceForce from './serviceForce/index.vue'
@Component({
  name: 'situational-awareness',
  components: {
    all,
    securityPeople,
    warningDetail,
    caseEvent,
    faceEarlyWarning,
    prohibitedProduct,
    actualTimeCar,
    coachBusWay,
    busWay,
    busStation,
    passengerStation,
    serviceForce
  }
})
export default class SituationalAwareness extends Vue {
  private currentTab = 'all'

  private defaultBottomSword: string = require('assets/images/bottom-sword.png')

  private activeBottomSword: string = require('assets/images/bottom-sword-active.png')

  private bottomTabList: Array<IMenuItem> = getBottomMenu()

  private changeTab(tab: string) {
    this.currentTab = tab
    switch (tab) {
      case 'all':
        this.currentTabCom = all
        break
      case 'security-people':
        this.currentTabCom = securityPeople
        break
      case 'warning-detail':
        this.currentTabCom = warningDetail
        break
      case 'case-event':
        this.currentTabCom = caseEvent
        break
      case 'face-early-warning':
        this.currentTabCom = faceEarlyWarning
        break
      case 'prohibited-product':
        this.currentTabCom = prohibitedProduct
        break
      case 'actual-time-car':
        this.currentTabCom = actualTimeCar
        break
      case 'coach-bus-way':
        this.currentTabCom = coachBusWay
        break
      case 'bus-way':
        this.currentTabCom = busWay
        break
      case 'bus-station':
        this.currentTabCom = busStation
        break
      case 'passenger-station':
        this.currentTabCom = passengerStation
        break
      case 'service-force':
        this.currentTabCom = serviceForce
        break
      default:
        this.currentTabCom = all
    }
  }

  private currentTabCom: any = all
}
</script>

<style lang="scss" scoped>
img {
  width: 100%;
  height: 100%;
  float: left;
}
.situational-awareness {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  &-content {
    width: 100%;
    height: calc(100% - 10px);
    margin-top: 10px;
  }
  .bottom-tab-list {
    width: 98%;
    height: 136px;
    position: absolute;
    left: 0;
    margin-left: 1%;
    bottom: 4px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('../../assets/images/bottom-tab-deep-bg.png') no-repeat;
    background-size: 100% 68px;
    background-position: 0% 68px;
    .tab-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 88px;
      height: 100%;
      cursor: pointer;
      .icon-container {
        width: 72px;
        height: 72px;
        transition: all linear 0.3s;
        flex-shrink: 0;
      }
      .bottom-sword {
        width: 40px;
        height: 20px;
        display: none;
        flex-shrink: 0;
      }
      .tip {
        font-size: 20px;
        line-height: 32px;
        font-family: 'PingFang Regular';
        color: #ffffff;
        height: 0px;
        opacity: 0;
        flex-shrink: 0;
      }
      & + .tab-item {
        margin-left: 8px;
      }
      &.active {
        justify-content: flex-end;
        .icon-container {
          width: 88px;
          height: 88px;
          transition: all linear 0.3s;
        }
        .bottom-sword {
          display: block;
        }
        .tip {
          height: 32px;
          opacity: 1;
          transition: opacity linear 0.3s;
        }
      }
      &:hover {
        justify-content: flex-end;
        .icon-container {
          width: 88px;
          height: 88px;
          transition: all linear 0.3s;
        }
        .bottom-sword {
          display: block;
        }
        .tip {
          height: 32px;
          opacity: 1;
          transition: opacity linear 0.3s;
        }
      }
    }
  }
}
</style>
